package github.fafaovo.common.item;

import github.fafaovo.common.Itemgroup.ExampleGroup;
import net.minecraft.entity.LivingEntity;
import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.item.Food;
import net.minecraft.item.Foods;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.potion.EffectInstance;
import net.minecraft.potion.Effects;
import net.minecraft.world.Explosion;
import net.minecraft.world.World;

public class examplelighter extends Item {
    private static final Food food = (new Food.Builder())
            .saturation(0) //饱腹度
            .hunger(0) //鸡腿
            .setAlwaysEdible() //满饱腹度也能吃
            .fastToEat() //吃的更快
            .build();


    public examplelighter() {
        super(new Item.Properties().group(ExampleGroup.exampleGroup).food(food));
    }

    @Override
    public ItemStack onItemUseFinish(ItemStack stack, World worldIn, LivingEntity entityLiving) {
        if(entityLiving instanceof PlayerEntity)
        {
            entityLiving.addPotionEffect(new EffectInstance(Effects.RESISTANCE,2,5));
            worldIn.createExplosion(null,
                    entityLiving.getPosX(),entityLiving.getPosY(),entityLiving.getPosZ(),
                    5,  //爆炸等级
                    Explosion.Mode.NONE //是否破坏方块
            );
        }
        return super.onItemUseFinish(stack, worldIn, entityLiving);
    }
}
